#include <stdio.h>
#include "UsbDevice.h"
#include "CBuffer.h"
#include "afxmt.h"

#define WM_USEV_MESSAGE				(WM_USER + 100)

class DeviceService {
public:
	DeviceService(UsbDevice *dev);
	DeviceService(void);
	~DeviceService(void);

public:
	enum DevMsg {
		DEV_MSG_PTX_LOST,
		DEV_MSG_PTX_FOUND,
		DEV_MSG_DATA_RX,
		DEV_MSG_PRX_LOST,
		DEV_MSG_PRX_FOUND,
	};
	CBuffer *readBuffer;
	CBuffer *writeBuffer;
	CMutex *readBufferMutex;
	CMutex *writeBufferMutex;

public:
	void Start(void);
	void Stop(void);
	int write(char *buffer, int len);
	void PostServiceMsg(enum DevMsg msg);
	
private: 
	UsbDevice *usbDevice;
	bool serviceStop;

private:
	static UINT DeviceService::ServiceThread(LPVOID *ptr);
};